<template>
  <div id="detail-tab-bar">
    <div
      v-for="(item, index) in titles"
      :key="index"
      :class="{ option: true, active: currentIndex === index }"
      @click="tabClick(index)">
      {{ item }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailTabBar',
  data () {
    return {
      // songList comment collector
      currentIndex: 0
    }
  },
  props: {
    titles: {
      type: Array,
      default () {
        return []
      }
    }
  },
  methods: {
    tabClick (index) {
      this.currentIndex = index
      this.$emit('tabClick', this.currentIndex)
    }
  }
}
</script>

<style scoped lang="less">
#detail-tab-bar {
  width: 100%;
  margin-right: 10px;
  padding-left: 100px;
  display: flex;
  border-bottom: 1px solid #e1e1e2;
  .option {
    user-select: none;
    cursor: pointer;
    padding: 5px 0;
    margin-right: 60px;
    border-bottom: 4px solid #fafafa;
    &.active {
      color: #c62f2f;
      border-bottom: 4px solid #c62f2f;
    }
  }
}
</style>
